/*	TargetedAbundanceAnalysisArgs.java
 *
 *	Copyright (c) Christopher Jacobs 2010
 *
 *	This file is part of Manatee ('this project').
 *
 *	This project is free software: you can redistribute it and/or modify it
 *	under the terms of the GNU General Public License as published by the Free
 *	Software Foundation, either version 3 of the License, or (at your option)
 *	any later version.
 *
 *	This project is distributed in the hope that it will be useful, but WITHOUT
 *	ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *	FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 *	more details.
 *
 *	You should have received a copy of the GNU General Public License along with
 *	this project. If not, see <http://www.gnu.org/licenses/>.
 */
package edu.bu.manateem.msg.analysis.io;

import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import edu.bu.manateem.msg.analysis.TargetedAbundanceAnalysis;
import edu.bu.manateem.msg.analysis.WidthPair;

/**
 *	<p>
 *	
 *	</p>
 *
 *
 *	@author
 *		Christopher Jacobs
 *
 *	@version
 *		1.0
 *
 *	@changelog
 *		Jun 11, 2010	- Version 1.0.
 */
public class TargetedAbundanceAnalysisArgs
	implements AnalysisArgs
{
	/*
	 * TYPES
	 */

	/*
	 * CONSTANTS
	 */

	/*
	 * FIELDS
	 */

	private Set<String> rawFiles = new HashSet<String>();
	private String targetFile = "";
	private double mzLeft =
		TargetedAbundanceAnalysis.DEFAULT_MZ_SUMWIDTH.doubleValue();
	private double mzRight =
		TargetedAbundanceAnalysis.DEFAULT_MZ_SUMWIDTH.doubleValue();
	private double rtSearch =
		TargetedAbundanceAnalysis.DEFAULT_RT_SEARCHWIDTH.doubleValue();
	private double rtSum =
		TargetedAbundanceAnalysis.DEFAULT_RT_SUMWIDTH.doubleValue();
	
	/*
	 * CONSTRUCTORS
	 */

	/*
	 * INITIALIZERS
	 */

	/*
	 * METHODS
	 */

	public WidthPair getMZSumWidth()
	{
		return new WidthPair(mzLeft,mzRight);
	}
	
	public Set<String> getRawFiles()
	{
		return rawFiles;
	}
	
	public WidthPair getRTSearchWidth()
	{
		return new WidthPair(rtSearch,rtSearch);
	}
	
	public WidthPair getRTSumWidth()
	{
		return new WidthPair(rtSum,rtSum);
	}
	
	public String getTargetFile()
	{
		return targetFile;
	}
	
	public boolean parse(List<String> args)
	{
		try
		{
			Iterator<String> iter = args.iterator();
			while (iter.hasNext())
			{
				String flag = iter.next();
				if (flag.matches("--mzLeft=.*"))
				{
					mzLeft = Double.parseDouble(flag.substring(9));
				}
				else if (flag.matches("--mzRight=.*"))
				{
					mzRight = Double.parseDouble(flag.substring(10));
				}
				else if (flag.matches("--rtSearch=.*"))
				{
					rtSearch = Double.parseDouble(flag.substring(11));
				}
				else if (flag.matches("--rtSum=.*"))
				{
					rtSum = Double.parseDouble(flag.substring(8));
				}
				else if (flag.matches("--raw=.*"))
				{
					rawFiles.add(flag.substring(6));
				}
				else if (flag.matches("--target=.*"))
				{
					targetFile = flag.substring(9);
				}
			}
		}
		catch (NumberFormatException x)
		{
			return false;
		}
		return true;
	}
}
